package cn.smart.epic.core.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.HashMap;
import java.util.Map;

/**
 * @Auther Z.B
 * @date 2017/10/11 14:16
 * @Email 2545375@qq.com
 * @Description 请输入你的描述
 * @since 1.0
 */

public class ConfigListener implements ServletContextListener {

    private static Map<String, String> conf = new HashMap<>();
    public static Map<String,String> getConf(){
        return conf;
    }

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        ServletContext sc = servletContextEvent.getServletContext();
        conf.put("realPath",sc.getRealPath("/").replace("/",""));
        conf.put("contextPath",sc.getContextPath());
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        conf.clear();
    }
}
